#仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作
class MyQueue:

    def __init__(self):
        #设置两个栈
        self.stack1=[]
        self.stack2=[]

    def push(self, x):
        #压入第一个栈
        self.stack1.append(x)

    def pop(self):
        #如果stack2里面还有元素,就不进行栈元素的转移工作
        if len(self.stack2)>0:
            return self.stack2.pop()
        #stack2里面没有元素了,需要将stack1里面的元素倒入stack2中
        while len(self.stack1):
            elem=self.stack1.pop()
            self.stack2.append(elem)
        return self.stack2.pop()
    def peek(self):
        if len(self.stack2)>0:
            return self.stack2[len(self.stack2)-1]
        else:
            return self.stack1[0]
    def empty(self):
        if len(self.stack2)==0 and len(self.stack1)==0:
            return True
        else:
            return False
obj=MyQueue()
obj.push(1)
print(obj.pop())
print(obj.empty())
obj.push(1)
obj.push(2)
obj.push(3)
print(obj.peek())
print(obj.pop())
# Your MyQueue object will be instantiated and called as such:
# obj = MyQueue()
# obj.push(x)
# param_2 = obj.pop()
# param_3 = obj.peek()
# param_4 = obj.empty()